<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //工厂模式: 类,耗内存
        function Person(name,age,hobby){
            let obj = {}// 添加原料
            obj.name = name
            obj.age = age
            obj.hobby = function(){
                console.log(hobby)
            }
            //加工原料
            return obj //出厂
        }
        let zhangsan = Person("张三",20,"喜欢篮球")

        //构造函数 1.首字母大写 2.this指向实例化对象 
        function Person(name){
            //this.num = 0
            this.name = name
            this.age = 20
        }
        Person.prototype.hobby = function(){
                console.log("喜欢篮球")
        }
        let lisi = new Person("李四")
        console.log(Person.prototype.constructor === Person)
    </script>
</body>
</html>